﻿using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Entities;

namespace BUS
{
    public class tbHinhAnhBus
    {
        public static void Insert_HinhAnh(tbHinhAnh hinhanh)
        {
            tbHinhAnhDAL hinhanhDAL = new tbHinhAnhDAL();
            hinhanhDAL.Insert(hinhanh);
        }
        public static void Update_HinhAnh(tbHinhAnh hinhanh)
        {
            tbHinhAnhDAL hinhanhDAL = new tbHinhAnhDAL();
            hinhanhDAL.Update(hinhanh);
        }
        public static void Delete_HinhAnh(int Id)
        {
            tbHinhAnhDAL hinhanhDAL = new tbHinhAnhDAL();
            hinhanhDAL.Delete(Id);
        }
        public static tbHinhAnh.tbHinhAnhCollection Get(string Where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {

            tbHinhAnhDAL hinhanhDAL = new tbHinhAnhDAL();
            return (hinhanhDAL.Get(Where, pageindex, pagesize, orderby, orderdirection, out total));
        }
        public static tbHinhAnh.tbHinhAnhCollection GetAll()
        {
            int total = 0;
            tbHinhAnhDAL hinhanhDAL = new tbHinhAnhDAL();
            return hinhanhDAL.Get("Where 1=1", 0, 0, tbHinhAnh.tbHinhAnhColumns.IDHinhAnh.ToString(), "ASC", out total);
        }
        public static tbHinhAnh GetByID(int iD)
        {
            int total = 0;
            tbHinhAnhDAL hinhanhDAL = new tbHinhAnhDAL();
            tbHinhAnh.tbHinhAnhCollection hinhanhcollection = hinhanhDAL.Get("where " + tbHinhAnh.tbHinhAnhColumns.IDHinhAnh.ToString() + "=" + iD.ToString(), 0, 0, tbHinhAnh.tbHinhAnhColumns.IDHinhAnh.ToString(), "ASC", out total);
            if (hinhanhcollection.Count > 0)
                return hinhanhcollection[0];
            return null;
        }

    } 
}
